package aop.common;

import javax.annotation.Resource;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import uri.model.MemberVO;

@Aspect
public class LoginMemberRankService {
	@Resource(name="loginMemberRankDAOImpl")
	private LoginMemberRankDAO loginMemberRankDAO;
	@Around("execution(public * uri.model.member.*Service.login(..))")
	public Object loginMemberRank(ProceedingJoinPoint point) throws Throwable{
		String targetClass=point.getTarget().getClass().getName();
		String methodName=point.getSignature().getName();
		Object params[]=point.getArgs();
		Object retValue=null;
		try {
			retValue = point.proceed();
			if(retValue!=null){
				MemberVO mvo=(MemberVO) retValue;
				String id=mvo.getId();
				int result=loginMemberRankDAO.isFirstLogin(id);
				if(result==0){
					loginMemberRankDAO.insertLoginId(id);
				}else{
					loginMemberRankDAO.updateLoginId(id);
				}
			}
		} catch (Throwable e) {
			throw e;
		} finally {
			
		}
		return retValue;
	}
}
